package com.group.product.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.group.commons.entity.ProductCategory;
import com.group.product.dao.ProductCategoryDao;
import com.group.product.service.ProductCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author :spj
 * @date:2022/6/7
 * @description:
 */
@Service
public class ProductCategoryServiceImpl implements ProductCategoryService {
    @Resource
    ProductCategoryDao productCategoryDao;

    @Override
    public List<ProductCategory> findAllProductCategories(IPage<ProductCategory> pages,ProductCategory category) {
        return productCategoryDao.selectAllProductCategories(pages,category);
    }

    @Override
    public Integer deleteProductCategory(int id) {
        return productCategoryDao.deleteById(id);
    }

    @Override
    public Integer addProductCategory(ProductCategory category,int fid) {
        category.setTime(new Date());
        return productCategoryDao.insertCategory(category,fid);
    }

    @Override
    public Integer changeCategory(ProductCategory category) {
        category.setTime(new Date());
        return productCategoryDao.updateCategory(category);
    }
}
